package com.cainiao.stock.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

//@Configuration
public class ThreadPoolExecutorConfiguration {

    //@Bean
    public ThreadPoolExecutor threadPoolExecutor(){
        int corePoolSize=2;
        int maximumPoolSize=10;
        long keepAliveTime=30;
        TimeUnit unit=TimeUnit.SECONDS;
        BlockingQueue<Runnable> workQueue=new ArrayBlockingQueue<>(10);
        ThreadFactory threadFactory=Executors.defaultThreadFactory();
        RejectedExecutionHandler handler=new ThreadPoolExecutor.AbortPolicy();
        return new ThreadPoolExecutor(corePoolSize,maximumPoolSize,keepAliveTime,unit,workQueue,threadFactory,handler);
    }
}
